<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s"  uri="/struts-tags" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
	<title>管理</title>
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.js" type="text/javascript"></script>
    <script src="js/jquery.twbsPagination.js" type="text/javascript"></script>   
    <script type="text/javascript">

    $(document).ready(function () {
	    $('#pagination-demo').twbsPagination({	    	
	        totalPages: ${pageCount},
	        visiblePages: ${pageCount}>10?10:${pageCount},
			startPage:${page},
	        version: '1.1',
	        first: "首页",
	        last: "未页",
	        prev: '上一页',
	        next: '下一页',
	        onPageClick: function (event, page) {	        	
	        	if(page!=${page}){
					//location.href="local_product_listByPage.action?page="+ page +"&rows=10";
	        		document.getElementById("queryForm").action="local_product_listByPage.action?page="+ page +"&rows=10";
	        		document.getElementById("queryForm").submit();
	        	}	        	
	        }
	    });
    });
    
    function dele(id)
    {
    	var r=confirm("是否删除？");
    	if(r)
   		{	
   			location.href='local_product_delete.action?id='+id;
   		}
    	
    }
    
    function exportExcel(){
    	var sku = $("#input_sku").val();
    	var category = $("#input_category").val();
    	window.location.href="<%=request.getContextPath()%>/local_product_excelExport?"
    	+"t1.sku="+sku+"&t1.category="+category;
    }
    </script>
</head>

<body>
<div class="panel panel-primary">
  <div class="panel-heading">管理 </div>
  <div class="panel-body"> 
  <form id="queryForm" class="form-horizontal" action="local_product_listByPage.action" method="post">
  	
  	<table>
  		<tr>
  			﻿<td>sku:</td>
  			<td><input type="text" value="${t1.sku }" name="t1.sku" class="form-control" id="input_sku" placeholder="" style="width: 150px"  ></td>
﻿<td>商品名称：</td>
  			<td><input type="text" value="${t1.category }" name="t1.category" class="form-control" id="input_category" placeholder="" style="width: 150px"  ></td>

  			<td><button type="submit" class="btn btn-default">查询</button></td>
  			<td><button type="button" onclick="location.href='local_productForm.jsp'" class="btn btn-default">增加</button></td>
  			<td><button type="button" onclick="exportExcel()" class="btn btn-default">导出excel</button>	</td>	
  		</tr>
  	</table>
  	
</form>
  
  </div>
		<table class="table table-bordered table-hover">
		    <thead>
			    <tr>
			         <th></th>
 <th></th>
 <th></th>

			        <th>操作</th>
			    </tr>
		    </thead>
		    <s:iterator value="#list">
			    <tr>
					 <th>${id }</th>
 <th>${sku }</th>
 <th>${category }</th>
			        
			        <td>
				        <a class="btn btn-primary btn-sm" href="local_product_get.action?id=${id }" role="button" >修改</a>
				        <a class="btn btn-primary btn-sm" onclick="dele(${id })" href="#" role="button" >删除</a>
			        </td>
			    </tr>        
		    </s:iterator>
		</table>

		<jsp:include page="page.jsp"></jsp:include>
  
</div>
</body>
</html>
